<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <style>
        .aui-list .aui-list-item-label,
        .aui-list .aui-list-item-label-icon {
            width: 100%;
        }

        .aui-switch:checked {
            border-color: #fd5454;
            background-color: #fd5454;
        }

        .aui-list .aui-list-item-input {
            text-align: right;
        }

        .aui-list .aui-list-item-input select {
            width: auto;
            display: inline-block;
        }

        .aui-radio:checked,
        .aui-radio.aui-checked,
        .aui-checkbox:checked,
        .aui-checkbox.aui-checked {
            background-color: #fd5454;
            border: solid 1px #fd5454;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="padding-top:25px">
        <a class="aui-pull-left" onclick="api.closeWin();">返回</a>
        <div class="aui-title">推送消息</div>
    </header>
    <div class="aui-content aui-margin-b-15 vue">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">接收推送</div>
                    <div class="aui-list-item-input">
                        <input type="checkbox" class="aui-switch" @change="changePushStatus" :checked="push_stop==0">
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <script type="text/javascript" src="../script/vue.js"></script>
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>
    <script type="text/javascript">
        apiready = function() {
            var ajpush = api.require('ajpush');

            var Ve = new Vue({
                el: '.vue',
                data: {
                    push_stop: 0
                },
                methods: {
                    changePushStatus: function() {
                        if (this.push_stop) {
                            if (api.systemType == 'android') {
                                ajpush.init(function(ret) {
                                    if (ret && ret.status) {

                                        ajpush.resumePush(function(ret) {
                                            if (ret && ret.status) {
                                                Ve.push_stop = 0
                                            }
                                        });

                                    }
                                });
                            }

                        } else {
                            if (api.systemType == 'android') {
                                ajpush.init(function(ret) {
                                    if (ret && ret.status) {

                                        ajpush.stopPush(function(ret) {
                                            if (ret && ret.status) {
                                                Ve.push_stop = 1
                                            }
                                        });
                                    }
                                });
                            }

                        }
                    }
                }
            })


            if (api.systemType == 'android') {
                ajpush.init(function(ret) {
                    if (ret && ret.status) {

                        ajpush.isPushStopped(function(ret) {
                            if (ret && ret.isStopped) {
                                Ve.push_stop = 1
                            }
                        });

                    }
                });
            }

        }
    </script>
</body>

</html>
